const mysql = require("mysql")

//创建链接对象
const con= mysql.createConnection({
    host:'localhost',
    user:'root',
    password:'root',
    port:'3306',
    database:'myblog'
})

//开始链接
con.connect()

//执行SQL语句
const sql ='select * from blogs;'
// const sql = 'select id,username from users;'
// const sql = `update users set realname='李四001' where username='lisi'`

// const sql =`insert into blogs (title,content,createtime,author) values ("标题F","内容F","1621006850793","乌巴")`





con.query(sql,(err,result)=>{
    if(err){
        console.log(err)
        return 
    }
    console.log(result)
})

//关闭链接
con.end()
